import { Route } from "react-router-dom/cjs/react-router-dom.min"
import Buy from "./movie/Buy"
import ChooseMovie from "./movie/ChooseMovie"
import { NavLink} from "react-router-dom"

const routes=[
    {
     path:'/',
     text:'影讯&购票 ',
     exact:true,
     component:Buy
    },
    {
        path:'/choose',
        text:'选电影',
        exact:true,
        component:ChooseMovie
       },
       {
        path:'/choose',
        text:'电视剧 ',
        exact:true,
        component:ChooseMovie
       },
       {
        path:'/choose',
        text:'排行榜 ',
        exact:true,
        component:ChooseMovie
       },
       {
        path:'/choose',
        text:'分类 ',
        exact:true,
        component:ChooseMovie
       },
       {
        path:'/choose',
        text:'影评 ',
        exact:true,
        component:ChooseMovie
       },   {
        path:'/choose',
        text:'2021年度榜单 ',
        exact:true,
        component:ChooseMovie
       },   {
        path:'/choose',
        text:'2021书影音报告',
        exact:true,
        component:ChooseMovie
       }
]
export default routes

export const makeRoutes=(routes,parentPath='')=>{
    return routes.map(({component:View,path,...route})=>{
        const currentPath=parentPath+path
        return(
            <Route key={currentPath} path={currentPath}{...route}>
       <Route path={ currentPath}/>
       <View/>
            </Route>
        )
    })
}
export const makeNavLinks = (routes, parentPath = '') => {
    return (
      <ul className="makeNavLinks">
        {routes.map(({ text, path}) => {
          const currentPath = parentPath + path
          return (
            <li key={currentPath}>
              <NavLink to={currentPath} exact>
                {text}
              </NavLink>
            </li>
          )
        })}
      </ul>
    )
  }
  
